//
//  YSGNurseAppointmentCell.swift
//  EyeVisionForPatients
//
//  Created by liuyutian on 2022/3/3.
//  Copyright © 2022 QDSG. All rights reserved.
//

import UIKit

class YSGNurseAppointmentCell: UITableViewCell {

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    func config(model : YSGNurseAppointmentModel){
        title.attributedText = NSMutableAttributedString(
            string: model.chargeItemName ?? "",
            attributes: [NSAttributedString.Key.font:
                UIFont(name: "PingFangSC-Semibold", size: 14.0)!])
        subTitle.attributedText = NSMutableAttributedString(
            string: "上门服务",
            attributes: [NSAttributedString.Key.font:
                UIFont(name: "PingFang SC", size: 12.0)!])
        let priceString = NSMutableAttributedString(
            string: (model.price ?? "") + "/" + (model.unit ?? "") + "起",
            attributes: [NSAttributedString.Key.font:
                UIFont(name: "PingFangSC-Semibold", size: 12.0)!])
        priceString.addAttribute(NSAttributedString.Key.foregroundColor,value:UIColor.warning, range: NSRange(location: 0,length: model.price?.count ?? 0))
        price.attributedText = priceString
    }
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
    }
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        selectionStyle = .none
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
     lazy var title: UILabel = {
        let label = UILabel(frame: CGRect(x: 20, y: 9, width: 280, height: 20))
         self.contentView.addSubview(label)
        return label
    }()
    
     lazy var subTitle: UILabel = {
        let label = UILabel(frame: CGRect(x: 20, y: 34, width: 100, height: 17))
         label.textColor = .textGray
         self.contentView.addSubview(label)
        return label
    }()
    
     lazy var price: UILabel = {
        let label = UILabel(frame: CGRect(x: 0, y: 20, width: screenW-40, height: 20))
        label.textAlignment = NSTextAlignment.right
         self.contentView.addSubview(label)
        return label
    }()
    
}
